.main-content {
    position: relative;
    margin-top: 74px;
    margin-left: 220px;
    width: calc(100% - 220px);
    height: calc(100vh - 74px);
    height: calc(100dvh - 74px);
    overflow: hidden;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgb(12, 12, 12);
    touch-action: none;
    overflow: hidden;
    user-select: none;
}

.pieces-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
}

.puzzle-piece {
    position: absolute;
    cursor: grab;
    z-index: 10;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
    transition: filter 0.2s, z-index 0s;
    will-change: transform, left, top;
    pointer-events: none;
}

.puzzle-piece .hit-area {
    pointer-events: all;
}

.puzzle-piece.dragging {
    z-index: 100;
    filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.7)) brightness(1.08);
}

.puzzle-piece.snapping {
    z-index: 50;
    transition: left 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.puzzle-piece.placed {
    cursor: default;
    z-index: 5;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.puzzle-piece.highlight-snap .piece-outline {
    stroke: #4df0ff;
    stroke-width: 4;
    filter: drop-shadow(0 0 2px #00a6ff) drop-shadow(0 0 1px #00a6ff);
}

.piece-outline {
    stroke: rgba(145, 198, 229, 0.95);
    stroke-width: 2;
}

.piece-svg {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 9999;
    padding: clamp(6px, 1vw, 10px) clamp(12px, 2vw, 20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    backdrop-filter: blur(4px);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn.active {
    background: #ff9800;
    border-color: #ff9800;
}

.panel {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px;
    border-radius: 10px;
    z-index: 500;
    font-size: clamp(10px, 1.5vw, 13px);
    width: clamp(180px, 25vw, 240px);
    display: none;
}

.panel button {
    margin: 3px;
    padding: 5px 10px;
    font-size: clamp(10px, 1.5vw, 13px);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.panel button.primary {
    background: #4CAF50;
    color: #fff;
}

.panel button.export {
    background: #2196F3;
    color: #fff;
}

.panel button.reset {
    background: #f44336;
    color: #fff;
}

.panel .status {
    margin-top: 5px;
    font-size: 11px;
    color: #aaa;
}

/* ===== MODAL: НАЧАЛО СБОРКИ ===== */

.puzzle-modal {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(6px);
}

.puzzle-modal-content {
    background: #111827;
    border-radius: 20px;
    padding: 40px 44px 36px;
    text-align: center;
    color: #e5e7eb;
    max-width: 520px;
    width: calc(100% - 40px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    animation: modalFadeIn 0.4s ease both;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.puzzle-modal-icon {
    width: 84px;
    height: 84px;
    margin-bottom: 20px;
    animation: modalIconIn 0.5s ease both;
}

.puzzle-modal-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

@keyframes modalIconIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.puzzle-modal-title {
    font-size: clamp(22px, 4vw, 28px);
    margin: 0 0 14px;
    font-weight: 700;
    color: #f9fafb;
    letter-spacing: 0.01em;
}

.puzzle-modal-lead {
    font-size: 15.5px;
    color: #9ca3af;
    line-height: 1.6;
    margin: 0 0 22px;
    max-width: 420px;
}

.puzzle-modal-hint {
    display: inline-block;
    margin-bottom: 24px;
    color: #9ca3af;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

#startPuzzleBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 40px;
    border-radius: 12px;
    border: none;
    background: #3b82f6;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.12s ease;
}

#startPuzzleBtn:hover {
    background: #2563eb;
}

#startPuzzleBtn:active {
    transform: scale(0.98);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== MODAL: СТАТИСТИКА СБОРКИ ===== */

#completionMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #111827;
    color: #e5e7eb;
    padding: 36px 44px 32px;
    border-radius: 20px;
    text-align: center;
    z-index: 99999;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    max-width: min(92%, 520px);
    min-width: 320px;
}

.completion-emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    margin: 0 auto 14px;
    animation: completionIconIn 0.5s ease both;
}

.completion-emoji svg {
    width: 100%;
    height: 100%;
    display: block;
}

@keyframes completionIconIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.completion-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 22px;
    color: #f9fafb;
    letter-spacing: 0.01em;
}

.completion-time {
    font-size: 38px;
    font-weight: 700;
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    color: #f9fafb;
}

.completion-avg {
    font-size: 14.5px;
    margin-bottom: 4px;
    color: #9ca3af;
}

.completion-comparison {
    font-size: 14.5px;
    margin-bottom: 26px;
    color: #9ca3af;
    line-height: 1.5;
}

.completion-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
}

.completion-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: #d1d5db;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.completion-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.24);
    color: #f9fafb;
}

.completion-action-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.completion-action-btn--accent {
    padding: 15px 40px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    border: none;
    background: #3b82f6;
    transition: background 0.2s ease, transform 0.12s ease;
}

.completion-action-btn--accent:hover {
    background: #2563eb;
    color: #fff;
}

.completion-action-btn--accent:active {
    transform: scale(0.98);
}

/* ===== EMBEDDED TEST ===== */

.game-container.puzzle-hidden>*:not(.test-container) {
    display: none !important;
}

.test-container {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: #0c1a2b;
    opacity: 0;
    transition: opacity 0.35s ease;
    overflow: hidden;
    pointer-events: none;
}

.test-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.test-container.hidden {
    display: none;
}

.test-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .puzzle-modal-content {
        padding: 32px 24px 28px;
        border-radius: 18px;
    }

    .puzzle-modal-icon {
        width: 68px;
        height: 68px;
        margin-bottom: 16px;
    }

    .puzzle-modal-lead {
        font-size: 15px;
    }

    #startPuzzleBtn {
        width: 100%;
        padding: 15px 24px;
        font-size: 15.5px;
    }

    #completionMessage {
        padding: 28px 24px 24px;
        border-radius: 18px;
        min-width: auto;
        width: calc(100% - 32px);
    }

    .completion-emoji {
        width: 64px;
        height: 64px;
        margin-bottom: 10px;
    }

    .completion-title {
        font-size: 20px;
        margin-bottom: 18px;
    }

    .completion-time {
        font-size: 30px;
    }

    .completion-avg,
    .completion-comparison {
        font-size: 14px;
    }

    .completion-action-btn--accent {
        width: 100%;
        padding: 14px 24px;
        font-size: 15px;
    }

    .completion-action-btn {
        width: 100%;
    }

    .completion-actions {
        flex-direction: column;
    }
}